// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import YP from "../../../sound/music";
import CustomButton from "../../BASE/CButton";
import ComponentBase from "../../BASE/ComponentBase";
import { gif } from "../../BASE/spineANDgif/gif";
import AnimalManager from "../../Manager/AnimalManager";
import GeZiManager from "../../Manager/GeZiManager";
import { Message } from "../../Message/Message";
import MessageCenter from "../../Message/MessageCenter";
import { SHMessage } from "../../Message/SHMessage";
import S03 from "../../Scharacter/S03";
import S05 from "../../Scharacter/S05";
import SXX from "../../Scharacter/SXX";
import A509 from "../../equipment/weapon/SC/A509";
import weapon from "../../equipment/weapon/weapon";

import state from "../../game/time/state";
import turn from "../../game/time/turn";
import KOG from "../KOG";
import shopM from "./ShopM";
import Shops from "./shops";

const {ccclass, property} = cc._decorator;

@ccclass
export default class shopUI extends ComponentBase {

    Sk:number=0;
    SUI:cc.Node=null;
    A1:cc.Node=null;
    A2:cc.Node=null;
    A3:cc.Node=null;
    A4:cc.Node=null;
    A5:cc.Node=null;
    A6:cc.Node=null;
    A7:cc.Node=null;
    Dqizi:cc.Node=null;
    DL:cc.Node=null;
    MU:cc.Node=null;
    leveUP:cc.Node=null;
    changL:cc.Node=null;
    AM:cc.Node=null
    @property({ type: cc.SpriteAtlas })
    Atlas: cc.SpriteAtlas = null;
    @property({ type: cc.SpriteAtlas })
    Atlas2: cc.SpriteAtlas = null;
    @property({ type: cc.SpriteAtlas })
    Atlas3: cc.SpriteAtlas = null;
yes:cc.Node;
DW:number=0;
i:number=1

onLoad(): void {
    this.MU=cc.find("Canvas/UIManager/magicUI");

   // this.SUI= cc.find("Canvas/UIManager/shopUI/1L/A1")
 this.A1= cc.find("Canvas/UIManager/shopUI/1L/A1")
 this.A2= cc.find("Canvas/UIManager/shopUI/1L/A2")
 this.A3= cc.find("Canvas/UIManager/shopUI/1L/A3")
 this.A4= cc.find("Canvas/UIManager/shopUI/1L/A4")
 this.A5= cc.find("Canvas/UIManager/shopUI/1L/A5")
 this.A6= cc.find("Canvas/UIManager/shopUI/2L/A6")
 this.A7= cc.find("Canvas/UIManager/shopUI/2L/A7")

 this.leveUP= cc.find("Canvas/UIManager/shopUI/3L/Leve")
 this.changL= cc.find("Canvas/UIManager/shopUI/3L/changL")
 this.AM=cc.find("Canvas/DituManager/New Node/AnimalManager")
}
shop(){    console.log(shopM.n)
    cc.find("Canvas").getComponent(YP).ZJP("uyp",false,2)
    console.log(shopM.A1n)

 for(let m of GeZiManager.PCP.shop1){m.Shop1();}  
    MessageCenter.MakeMessage("UIManager","change",3);
this.ST();
   
   }
shopX(){
    MessageCenter.MakeMessage("UIManager","change",1);
    cc.find("Canvas").getComponent(YP).ZJP("uyp",false,2)
    for(let m of GeZiManager.PCP.shop3){m.Shop3();}
GeZiManager.PCP.ST();
}


dA1(){

    MessageCenter.MakeGMessage("SU",[GeZiManager.PCP.ZB],1,GeZiManager.PCP.Pturn,"buy")
//MessageCenter.MakeMessage("BUI",[3],"Ban");
MessageCenter.MakeMessage("UIManager","change",1);
}


dA2(){
 
    MessageCenter.MakeGMessage("SU",[GeZiManager.PCP.ZB],2,GeZiManager.PCP.Pturn,"buy")
    MessageCenter.MakeMessage("UIManager","change",1);

}
    dA3(){
 
        MessageCenter.MakeGMessage("SU",[GeZiManager.PCP.ZB],3,GeZiManager.PCP.Pturn,"buy")
        MessageCenter.MakeMessage("UIManager","change",1);


    }

    dA4(){
      
        MessageCenter.MakeGMessage("SU",[GeZiManager.PCP.ZB],4,GeZiManager.PCP.Pturn,"buy")
        MessageCenter.MakeMessage("UIManager","change",1);
           }
    
       
    
    
    
    
    
        dA5(){
           
            MessageCenter.MakeGMessage("SU",[GeZiManager.PCP.ZB],5,GeZiManager.PCP.Pturn,"buy")
            MessageCenter.MakeMessage("UIManager","change",1);}
    
dilei(){
    cc.find("Canvas").getComponent(YP).ZJP("uyp",false,1)
GeZiManager.qing()
    MessageCenter.MakeMessage("AM",turn.turn,"getZB")
    GeZiManager.FTPN=3;
GeZiManager.JL=4;
   state.ST=2;
           
            
   
   MessageCenter.MakeMessage("UIManager","change",-1);
 

   for(let manager of GeZiManager.YuanGong){
  
  manager.getFar(GeZiManager.JL);
if(GeZiManager.BanMove.includes(manager.ZB)||GeZiManager.qins.includes(manager.ZB)){
     manager.red()}
     if(GeZiManager.AllObstacles[0]!=null){
     for(let a of GeZiManager.AllObstacles){
      if(a.ZB==manager.ZB&&!(GeZiManager.grass.includes(a.ZB)&&a.ObstaclesName!="qizi")){manager.red()}
  if(a.tt=="flag"&&a.FW.includes(manager.ZB)&&a.color!=GeZiManager.PCP.color&&a.color!="S02"){manager.red()}
    
    }}
}

}



qizi(){ 
  cc.find("Canvas").getComponent(YP).ZJP("uyp",false,2)

    MessageCenter.MakeMessage("AM",turn.turn,"getZB")
    GeZiManager.FTPN=8;
GeZiManager.JL=2;
   state.ST=2;
           
            
   
   MessageCenter.MakeMessage("UIManager","change",-1);
 
   console.log(this.AM.getComponent(AnimalManager).YuanGong)
   for(let manager of GeZiManager.YuanGong){
  
  manager.getFar(GeZiManager.JL);

  
   
    if(GeZiManager.BanMove.includes(manager.ZB)&&(this.getTeamZB(GeZiManager.PCP.Pturn,manager.ZB)==false)){
     manager.red()}
     
  if(GeZiManager.AllObstacles[0]!=null){
     for(let a of GeZiManager.AllObstacles){
      if(a.ZB==manager.ZB){manager.red()}
    
    
    }}

}
}
qic(qic:number){
  
    MessageCenter.MakeMessage("AM",turn.turn,"getQi")
    MessageCenter.MakeMessage("AM",turn.turn,"getZB")
if(GeZiManager.Qi>=qic){    MessageCenter.MakeSHMessage("AM",[GeZiManager.GeZi],qic,null,"Qi-");

GeZiManager.free=0;
return true}else{
    
   for(let ma of GeZiManager.label){
    ma.Fqic();
   }
    
    
    return false}


 } 


dleveUP(){
   
 //cc.find("Canvas").getComponent(YP).ZJP("uyp",false,5)

    MessageCenter.MakeGMessage("SU",[GeZiManager.PCP.ZB],5+this.i,GeZiManager.PCP.Pturn,"buy")

MessageCenter.MakeMessage("UIManager","change",1);

}






changI(){
 cc.tween(cc.find("Canvas/UIManager/shopUI/3L/changL")).to(0.3,{angle:cc.find("Canvas/UIManager/shopUI/3L/changL").angle-180}).start()
   setTimeout(() => {
    switch (this.i) {
        case 1:this.i=2;
            
            break;
    case 2:this.i=1;
        default:
            break;
    }
    this.ST();
   },90);
 
   cc.find("Canvas").getComponent(YP).ZJP("uyp",false,4)


}

  STT(){
   
    
    
    
    
    
    let t
    if(GeZiManager.free!=0){t=GeZiManager.free+""}else if(GeZiManager.free>0){t="+"+GeZiManager.free}else{t=""}
    
    this.A1.getChildByName("xLabel").getComponent(cc.Label).string="售价为"+shopM.A1n[0]+t+"  剩"+shopM.A1n[1]+"个"
    this.A2.getChildByName("xLabel").getComponent(cc.Label).string="售价为"+shopM.A2n[0]+t+"  剩"+shopM.A2n[1]+"个"
    this.A3.getChildByName("xLabel").getComponent(cc.Label).string="售价为"+shopM.A3n[0]+t+"  剩"+shopM.A3n[1]+"个"
    this.A4.getChildByName("xLabel").getComponent(cc.Label).string="售价为"
    this.A5.getChildByName("xLabel").getComponent(cc.Label).string="售价为"
        //this.A5.getChildByName("a5p").getComponent(cc.Sprite).spriteFrame=a5p;
       // this.A5.getChildByName("a5p").getComponent(cc.Sprite).spriteFrame=a5p;
  
    let dll;let PS;
    switch (GeZiManager.PCP.weapon.getComponent(weapon).TheNumber) {
        case "A000":dll="";PS=null;
              
        break;
        case "A110": switch(shopM.i){
    
    
            case 1:dll=2+GeZiManager.free+"气,A131";PS=this.AM.getComponent(Shops).find(6,"A131");
          
             break;
        
            case 2:dll=2+GeZiManager.free+"气,A132";PS=this.AM.getComponent(Shops).find(6,"A132");
            break;
         }
      
         break;
        case "A132":dll=4+GeZiManager.free+"气,A152";PS=this.AM.getComponent(Shops).find(6,"A152");
            break;
        case "A131":dll=4+GeZiManager.free+"气,A151";PS=this.AM.getComponent(Shops).find(6,"A153");
        break;  
        case "A210": switch(shopM.i){
    
    
            case 1:dll=3+GeZiManager.free+"气,A231";PS=this.AM.getComponent(Shops).find(6,"A231");
            break;  
             break;
        
            case 2:dll=3+GeZiManager.free+"气,A232";PS=this.AM.getComponent(Shops).find(6,"A232");
            break;
         }
      
         break;
        case "A232":dll=3+GeZiManager.free+"气,A252";PS=this.AM.getComponent(Shops).find(6,"A252");
              
            break;
        case "A231":dll=3+GeZiManager.free+"气,A251";PS=this.AM.getComponent(Shops).find(6,"A251");
        break;
        case "A310": switch(shopM.i){
    
    
            case 1:dll=3+GeZiManager.free+"气,A331";PS=this.AM.getComponent(Shops).find(2,"A331");
             break;
        
            case 2:dll=2+GeZiManager.free+"气,A332";PS=this.AM.getComponent(Shops).find(2,"A332");
            break;
         }
      
         break;
        case "A332":dll=3+GeZiManager.free+"气,A352";PS=this.AM.getComponent(Shops).find(2,"A352");
              
            break;
        case "A331":dll=2+GeZiManager.free+"气,A351";PS=this.AM.getComponent(Shops).find(2,"A351");
        break;
        case "A503":dll=4+GeZiManager.free+"气,"+(GeZiManager.PCP.getComponent(S03).MZ+1)+"级法杖"
        break;
        case "A509":dll=4+GeZiManager.free+"气,"+(GeZiManager.PCP.weapon.getComponent(A509).MZ+1)+"级攻击环"
        break;
    }      
    
    this.leveUP.getChildByName("xLabel").getComponent(cc.Label).string=dll;this.leveUP.getChildByName("PS").getComponent(cc.Sprite).spriteFrame=PS;
 let a;
    switch (GeZiManager.PCP.weapon.getComponent(weapon).TheNumber){
        case "A000":a.push(56);  break;
        case "A110": if(GeZiManager.PCP.qi<2+GeZiManager.free){a.push(56)}
            break;
        
        
        
        case "A131": if(GeZiManager.PCP.qi<4+GeZiManager.free){a.push(56)}       
                break;
         case "A132": if(GeZiManager.PCP.qi<4+GeZiManager.free){a.push(56)}
            break;
            
         case "A210": if(GeZiManager.PCP.qi<3+GeZiManager.free){a.push(56)}
       
         break;
         case "A210": if(GeZiManager.PCP.qi<3+GeZiManager.free){a.push(56)}
       
         break;
        case "A232":  if(GeZiManager.PCP.qi<3+GeZiManager.free){a.push(56)}
            break;
        case "A231":  if(GeZiManager.PCP.qi<3+GeZiManager.free){a.push(56)}
        break;
        case "A332":  if(GeZiManager.PCP.qi<3+GeZiManager.free){a.push(56)}
        break;
    case "A331":  if(GeZiManager.PCP.qi<3+GeZiManager.free){a.push(56)}
    break;
        
            
            
        case "A310":  if(GeZiManager.PCP.qi<2+GeZiManager.free){a.push(56)}
        break;
        ;   
            
            
        case "A503":if(GeZiManager.PCP.qi<4+GeZiManager.free&&GeZiManager.PCP.getComponent(S03).MZ==3){a.push(56)}
        break; 
             
        case "A509":if(GeZiManager.PCP.qi<4+GeZiManager.free||GeZiManager.PCP.weapon.getComponent(A509).MZ==3){a.push(56)}
        break;     
            
                default:a.push(56);a.push(57);break;
                






    }
    
    if((GeZiManager.PCP.qi<shopM.A1n[0]+GeZiManager.free)||shopM.A1n[1]<=0){a.push(51)
   }
   if((GeZiManager.PCP.qi<shopM.A2n[0]+GeZiManager.free)||shopM.A2n[1]<=0){a.push(52)
   }
   if((GeZiManager.PCP.qi<shopM.A3n[0]+GeZiManager.free)||shopM.A3n[1]<=0){a.push(53)
   }
   if((GeZiManager.PCP.qi<3+GeZiManager.free+turn.day)){a.push(54)
   }
if((GeZiManager.PCP.qi<3+GeZiManager.free+turn.day)){a.push(55)
   }
   
   
   MessageCenter.MakeMessage("BUI",[51,52,53,54,55,56,57],"Use")
   //if
   MessageCenter.MakeMessage("BUI",a,"Ban")
}



getTeamZB(n:number,ZB:number){
    for(let a of this.AM.getComponent(AnimalManager).YuanGong){
    
        if(a.ZB==ZB){
        
    
        if(a.Pturn!=0&&(a.Pturn%2==n%2)){return true}else{return false}
}
    
    
   
    
    }
}

ST(){
  //1L

  console.log(shopM.A1n[1])
    let t
    if(GeZiManager.free!=0){t=GeZiManager.free+""}else if(GeZiManager.free>0){t="+"+GeZiManager.free}else{t="";}
    this.A1.getChildByName("Background").children[0].getComponent(cc.Label).string=""+shopM.A1n[0]+t;

    this.A2.getChildByName("Background").children[0].getComponent(cc.Label).string=""+shopM.A2n[0]+t;

    this.A3.getChildByName("Background").children[0].getComponent(cc.Label).string=""+shopM.A3n[0]+t;
    if (!shopM.A1n[2]) {
        this.A1.getChildByName("Y").active=false;
    }else{this.A1.getChildByName("Y").active=true;this.A1.getChildByName("Y").children[0].getComponent(cc.Label).string=""+shopM.A1n[2]; }
    if (!shopM.A2n[2]) {
       this.A2.getChildByName("Y").active=false;
    }else{this.A2.getChildByName("Y").active=true;this.A2.getChildByName("Y").children[0].getComponent(cc.Label).string=""+shopM.A2n[2]; }
    if (!shopM.A3n[2]) {
       this.A3.getChildByName("Y").active=false;
    }else{this.A3.getChildByName("Y").active=true;this.A3.getChildByName("Y").children[0].getComponent(cc.Label).string=""+shopM.A3n[2]; }
    
    





    if(GeZiManager.PCP.qi<shopM.A1n[0]+GeZiManager.free||shopM.A1n[1]==0){this.A1.getComponent(CustomButton).disableButton()}else{this.A1.getComponent(CustomButton).enableButton();}
    if(GeZiManager.PCP.qi<shopM.A2n[0]+GeZiManager.free||shopM.A2n[1]==0){this.A2.getComponent(CustomButton).disableButton()}else{this.A2.getComponent(CustomButton).enableButton();}
    if(GeZiManager.PCP.qi<shopM.A3n[0]+GeZiManager.free||shopM.A3n[1]==0){this.A3.getComponent(CustomButton).disableButton()}else{this.A3.getComponent(CustomButton).enableButton();}

    let k=1
   
//if(turn.round>=2){

    if (shopM.A1n[1]!=0) {
        this.A1.getChildByName("Y").getChildByName("New Sprite").getComponent(cc.Sprite).spriteFrame=this.AM.getComponent(Shops).find(10,shopM.A1n[2]) 

          KOG.DSP( this.A1.getChildByName("Y").getChildByName("New Sprite"),shopM.A1n[2])
    }
    if (shopM.A2n[1]!=0) {
        this.A2.getChildByName("Y").getChildByName("New Sprite").getComponent(cc.Sprite).spriteFrame=this.AM.getComponent(Shops).find(10,shopM.A2n[2]) 
        KOG.DSP( this.A2.getChildByName("Y").getChildByName("New Sprite"),shopM.A2n[2])
    }

    if (shopM.A3n[1]!=0) {
        this.A3.getChildByName("Y").getChildByName("New Sprite").getComponent(cc.Sprite).spriteFrame=this.AM.getComponent(Shops).find(10,shopM.A3n[2]) 
        KOG.DSP( this.A3.getChildByName("Y").getChildByName("New Sprite"),shopM.A3n[2])
    }



    if(shopM.A4n){
    this.A4.getChildByName("xLabel").getComponent(cc.Label).string=k+GeZiManager.free+turn.day+""
    this.A4.getChildByName("Background").children[0].getComponent(cc.Label).string=""+shopM.A4n
    this.A4.getChildByName("Y").getChildByName("New Sprite").getComponent(cc.Sprite).spriteFrame=this.AM.getComponent(Shops).find(10,shopM.A4n)
    KOG.DSP( this.A4.getChildByName("Y").getChildByName("New Sprite"),shopM.A4n)
    this.A4.children[0].active=true;
    if(GeZiManager.PCP.qi<k+GeZiManager.free+turn.day){this.A4.getComponent(CustomButton).disableButton();}else{this.A4.getComponent(CustomButton).enableButton();}
}else{ this.A4.getChildByName("xLabel").getComponent(cc.Label).string=""
this.A4.getChildByName("Background").children[0].getComponent(cc.Label).string="?"
this.A4.getComponent(CustomButton).disableButton();
this.A4.children[0].active=false;
this.A4.getChildByName("Y").getChildByName("New Sprite").getComponent(cc.Sprite).spriteFrame=null}
if(shopM.A5n){
    this.A5.getChildByName("xLabel").getComponent(cc.Label).string=k+GeZiManager.free+turn.day+""
    this.A5.getChildByName("Background").children[0].getComponent(cc.Label).string=""+shopM.A5n
    this.A5.getChildByName("Y").getChildByName("New Sprite").getComponent(cc.Sprite).spriteFrame=this.AM.getComponent(Shops).find(10,shopM.A5n)
    KOG.DSP( this.A5.getChildByName("Y").getChildByName("New Sprite"),shopM.A5n)
    this.A5.children[0].active=true;
    if(GeZiManager.PCP.qi<k+GeZiManager.free+turn.day){this.A5.getComponent(CustomButton).disableButton();}else{this.A5.getComponent(CustomButton).enableButton();}
}else{ this.A5.getChildByName("xLabel").getComponent(cc.Label).string=""
this.A5.getChildByName("Background").children[0].getComponent(cc.Label).string="?"
this.A5.getComponent(CustomButton).disableButton();
this.A5.children[0].active=false;
this.A5.getChildByName("Y").getChildByName("New Sprite").getComponent(cc.Sprite).spriteFrame=null
}




//}else{this.A4.getComponent(CustomButton).disableButton();this.A5.getComponent(CustomButton).disableButton();}
////////////////


/////////////////////////dilei
if(GeZiManager.PCP.DLN==0){this.A6.getChildByName("DLban").active=true;}else{this.A6.getChildByName("DLban").active=false}
this.A6.getChildByName("Background").active=true;
if(shopM.A6n[1]==0||GeZiManager.PCP.qi<shopM.A6n[0]+GeZiManager.free||GeZiManager.PCP.DLN==0){this.A6.getComponent(CustomButton).disableButton();
    if(shopM.A6n[1]==0){this.A6.getChildByName("Background").active=false}}
else{this.A6.getComponent(CustomButton).enableButton();}
this.A6.getChildByName("DLn").getComponent(gif).changeF(shopM.A6n[1]+2,1);
this.A6.getChildByName("xLabel").getComponent(cc.Label).string=""+shopM.A6n[0]
////////
//////qizi
if(GeZiManager.PCP.qi>=shopM.A7n[0]+GeZiManager.free){
this.A7.getChildByName("Blue").getComponent(CustomButton).enableButton();
    this.A7.getChildByName("Red").getComponent(CustomButton).enableButton();}else{this.A7.getChildByName("Blue").getComponent(CustomButton).disableButton();
    this.A7.getChildByName("Red").getComponent(CustomButton).disableButton();}
if(shopM.A7n[2]==0){this.A7.getChildByName("Blue").active=false}else{this.A7.getChildByName("Blue").active=true}
if(shopM.A7n[1]==0){this.A7.getChildByName("Red").active=false}else{this.A7.getChildByName("Red").active=true}
       
        
     switch (GeZiManager.PCP.color) {
        case "Blue":    this.A7.getChildByName("Red").getComponent(CustomButton).disableButton();
            
            break;
     
        default:  this.A7.getChildByName("Blue").getComponent(CustomButton).disableButton()
            break;
     }  
 ////////////////////////////    
     


switch (this.i) {
    case 2:this.fadeOutAndDisappear(cc.find("Canvas/UIManager/shopUI/3L/Leve/PS"),100);this.fadeINAndA(cc.find("Canvas/UIManager/shopUI/3L/Leve/PS2"),100)
        
        break;

    default:this.fadeOutAndDisappear(cc.find("Canvas/UIManager/shopUI/3L/Leve/PS2"),100);this.fadeINAndA(cc.find("Canvas/UIManager/shopUI/3L/Leve/PS"),100)
        break;
}
//////////////////

this.SJPD();
this.node.getChildByName("TN").getComponent(gif).changeF(this.getTNC(5)-1,1)
if(GeZiManager.PCP.TN<this.getTNC(5)){
    
    this.A1.getComponent(CustomButton).disableButton();
    this.A2.getComponent(CustomButton).disableButton();
    this.A3.getComponent(CustomButton).disableButton();
    this.A4.getComponent(CustomButton).disableButton();
    this.A5.getComponent(CustomButton).disableButton();
    this.A6.getComponent(CustomButton).disableButton();
    this.A7.getChildByName("Blue").getComponent(CustomButton).disableButton()
    this.A7.getChildByName("Red").getComponent(CustomButton).disableButton()
    this.leveUP.getComponent(CustomButton).disableButton()
}



if (!GeZiManager.PCP.getComponent(SXX).ZZ.includes("human")&&!GeZiManager.PCP.getComponent(SXX).ZZ.includes("EM")) {
    this.A1.getComponent(CustomButton).disableButton();
    this.A2.getComponent(CustomButton).disableButton();
    this.A3.getComponent(CustomButton).disableButton();

    if (shopM.A4n&&shopM.A4n[0]!="D") {
        this.A4.getComponent(CustomButton).disableButton();
    }

    if (shopM.A5n&&shopM.A5n[0]!="D") {
        this.A5.getComponent(CustomButton).disableButton();
    }

}else{
switch (GeZiManager.PCP.getComponent(SXX).Snumber) {
    case "S04":  
    
    if (shopM.A2n[2]&&shopM.A2n[2][1]!="1"&&shopM.A2n[2][0]=="A") {
        this.A2.getComponent(CustomButton).disableButton();
    }
    if (shopM.A3n[2]&&shopM.A3n[2][1]!="1"&&shopM.A3n[2][0]=="A") {
        this.A3.getComponent(CustomButton).disableButton();
    }  
    if (shopM.A1n[2]&&shopM.A1n[2][1]!="1"&&shopM.A1n[2][0]=="A") {
        this.A1.getComponent(CustomButton).disableButton();
    }

    if (shopM.A4n&&shopM.A4n[1]!="1"&&shopM.A4n[0]=="A") {
        this.A4.getComponent(CustomButton).disableButton();
    }

    if (shopM.A5n&&shopM.A5n[1]!="1"&&shopM.A5n[0]=="A") {
        this.A5.getComponent(CustomButton).disableButton();
    }
        break;
/*        
case"S05":if (GeZiManager.PCP.getComponent(S05).xjj>0) {
    this.A1.getComponent(CustomButton).disableButton();
    this.A2.getComponent(CustomButton).disableButton();
    this.A3.getComponent(CustomButton).disableButton();
    if (shopM.A4n&&shopM.A4n[0]=="A") {
        this.A4.getComponent(CustomButton).disableButton();
    }

    if (shopM.A5n&&shopM.A5n[0]=="A") {
        this.A5.getComponent(CustomButton).disableButton();
    }
    this.leveUP.getComponent(CustomButton).disableButton()
}
break;*/
case"S08":
    this.A1.getComponent(CustomButton).disableButton();
    this.A2.getComponent(CustomButton).disableButton();
    this.A3.getComponent(CustomButton).disableButton();
    if (shopM.A4n&&shopM.A4n[0]=="A") {
        this.A4.getComponent(CustomButton).disableButton();
    }

    if (shopM.A5n&&shopM.A5n[0]=="A") {
        this.A5.getComponent(CustomButton).disableButton();
    }
  

    default:
        break;
}

}



      }

////////////////////

SJPD(){
console.log(GeZiManager.PCP.weapon.TheNumber)
let dll,PS,n=null
switch (GeZiManager.PCP.weapon.TheNumber) {
    case "A000":dll="";PS=null;n=null
              
    break;
    case "A110": switch(this.i){


        case 1:dll=2+GeZiManager.free+"气,A131";PS=this.AM.getComponent(Shops).find(10,"A131");
      
         break;
    
        case 2:dll=2+GeZiManager.free+"气,A132";PS=this.AM.getComponent(Shops).find(10,"A132");
        break;
     }
  n=2
     break;
    case "A132":dll=4+GeZiManager.free+"气,A152";PS=this.AM.getComponent(Shops).find(10,"A152");n=4
        break;
    case "A131":dll=4+GeZiManager.free+"气,A151";PS=this.AM.getComponent(Shops).find(10,"A151");n=4
    break;  
    case "A210": switch(this.i){


        case 1:dll=3+GeZiManager.free+"气,A231";PS=this.AM.getComponent(Shops).find(10,"A231");
        break;  
         break;
    
        case 2:dll=3+GeZiManager.free+"气,A232";PS=this.AM.getComponent(Shops).find(10,"A232");
        break;
     }
  n=3
     break;
    case "A232":dll=3+GeZiManager.free+"气,A252";PS=this.AM.getComponent(Shops).find(10,"A252");
          n=3
        break;
    case "A231":dll=3+GeZiManager.free+"气,A251";PS=this.AM.getComponent(Shops).find(10,"A251");n=3
    break;
    case "A310": switch(this.i){


        case 1:dll=2+GeZiManager.free+"气,A331";PS=this.AM.getComponent(Shops).find(10,"A331");n=3
         break;
    
        case 2:dll=2+GeZiManager.free+"气,A332";PS=this.AM.getComponent(Shops).find(10,"A332");n=2
        break;
     }
  
     break;
    case "A332":dll=3+GeZiManager.free+"气,A352";PS=this.AM.getComponent(Shops).find(10,"A352");n=3
          
        break;
    case "A331":dll=3+GeZiManager.free+"气,A351";PS=this.AM.getComponent(Shops).find(10,"A351");n=2
    break;

    case "A121": PS=this.AM.getComponent(Shops).find(10,"A146") ; n=5;
    break
    case "A122":PS=this.AM.getComponent(Shops).find(10,"A144") ; n=4;
    break
    case "A125": PS=this.AM.getComponent(Shops).find(10,"A141") ; n=4;
    break
    case "A126": PS=this.AM.getComponent(Shops).find(10,"A145") ; n=3;
    break
    case "A127": PS=this.AM.getComponent(Shops).find(10,"A142") ; n=3;
    break
    case "A128": PS=this.AM.getComponent(Shops).find(10,"A147") ; n=3;
    break
    case "A141": PS=this.AM.getComponent(Shops).find(10,"A161") ; n=5;
    break
    case "A142": PS=this.AM.getComponent(Shops).find(10,"A162") ; n=6;
    break
    case "A223": PS=this.AM.getComponent(Shops).find(10,"A262") ; n=6;
    break
    case "A228": PS=this.AM.getComponent(Shops).find(10,"A242") ; n=3;
    break
    case "A242": PS=this.AM.getComponent(Shops).find(10,"A263") ; n=5;
    break
    case "A321": PS=this.AM.getComponent(Shops).find(10,"A321P") ; n=2;
    break
    case "A321P": PS=this.AM.getComponent(Shops).find(10,"A352") ; n=4;
    break
    case "A322": PS=this.AM.getComponent(Shops).find(10,"A342") ; n=2;
    break
    case "A345": PS=this.AM.getComponent(Shops).find(10,"A361") ; n=5;
    break



    case "A580": switch(this.i){


        case 1:dll=2+GeZiManager.free+"气,A581";PS=this.AM.getComponent(Shops).find(10,"A581");n=2
         break;
    
        case 2:dll=2+GeZiManager.free+"气,A582";PS=this.AM.getComponent(Shops).find(10,"A582");n=2
        break;
     }
   
      
     case "A581":switch(this.i){


        case 1:dll=2+GeZiManager.free+"气,A582";PS=this.AM.getComponent(Shops).find(10,"A582");n=2
         break;
    
        case 2:dll=2+GeZiManager.free+"气,A583";PS=this.AM.getComponent(Shops).find(10,"A583");n=2
        break;
     }
         break;
    
         case "A582":switch(this.i){


            case 1:dll=2+GeZiManager.free+"气,A581";PS=this.AM.getComponent(Shops).find(10,"A581");n=2
             break;
        
            case 2:dll=2+GeZiManager.free+"气,A583";PS=this.AM.getComponent(Shops).find(10,"A583");n=2
            break;
         }

         case "A583":dll=2+GeZiManager.free+"气,A583P";PS=this.AM.getComponent(Shops).find(10,"A583P");n=3
         break;


case "A583P":dll=2+GeZiManager.free+"气,A583P";PS=this.AM.getComponent(Shops).find(10,"A583P");n=3
         break;
  
   
    case "A503":dll=2+GeZiManager.free+"气,"+(GeZiManager.PCP.getComponent(S03).MZ+1)+"级法杖";n=2
    break;
    case "A509":dll=4+GeZiManager.free+"气,"+(GeZiManager.PCP.weapon.getComponent(A509).MZ+1)+"级攻击环";n=4
    break;
    case "A504":dll=2+GeZiManager.free+"气";PS=this.AM.getComponent(Shops).find(10,"A110");n=2
    break;
}      

this.leveUP.getChildByName("xLabel").getComponent(cc.Label).string=n+"";this.leveUP.children[5].getChildByName("P").getComponent(cc.Sprite).spriteFrame=PS;

if(n!=null&&GeZiManager.PCP.qi>=n+GeZiManager.free){this.leveUP.getComponent(CustomButton).enableButton();    this.leveUP.children[2].color=cc.color(206,255,244)}else{this.leveUP.getComponent(CustomButton).disableButton();cc.color(235,68,68)}

if (n==null) {
    this.leveUP.children[5].active=false;
    this.leveUP.children[1].active=false;
    this.leveUP.children[2].active=false;

}else{
this.fadeINAndA(this.leveUP.children[5],400)
   
    this.leveUP.children[1].active=true;
    this.leveUP.children[2].active=true;
}


if (PS) {
    KOG.DSP(this.leveUP.children[5].getChildByName("P"),PS.name)
}


}
getTNC(n:number){


    let k=  GeZiManager.PCP.TNJJ
    let l =GeZiManager.TNC
   if(k[n]+l[n]>=0){return k[n]+l[n]}else {return 0}
   }




   YFH(){let o ,j ;
    j=[]
if (GeZiManager.PCP.color=="Blue") {
  o=[GeZiManager.P1,GeZiManager.P3,GeZiManager.P5]
}else {o=[GeZiManager.P2,GeZiManager.P4,GeZiManager.P6]
}
for(let a of o){

if (a.LST<0) {
    j.push(a.Pturn)
}

}
console.log(j)

for (let index = 1; index <= 6; index++) {
    this.node.children[5].children[index].active=false
     
 }
for (let index = 0; index < j.length; index++) {
   this.node.children[5].children[j[index]].active=true
    
}

}

fh1(){

 this.NWFH(1)   
}


fh2(){

    this.NWFH(2)   
   }

   fh3(){

    this.NWFH(3)   
   }

   fh4(){

    this.NWFH(4)   
   }

   fh5(){

    this.NWFH(5)   
   }

   fh6(){

    this.NWFH(6)   
   }
               
   NWFH(n:number){
    state.ST=0.5
    switch (n) {
        case 1:GeZiManager.Tcharacter=GeZiManager.P1
            
            break;
            case 2:GeZiManager.Tcharacter=GeZiManager.P2
            
            break;
            case 3:GeZiManager.Tcharacter=GeZiManager.P3
            
            break;
            case 4:GeZiManager.Tcharacter=GeZiManager.P4
            
            break;
            case 5:GeZiManager.Tcharacter=GeZiManager.P5
            
            break;
            case 6:GeZiManager.Tcharacter=GeZiManager.P6
            
            break;
        default:
            break;
    }
        MessageCenter.MakeMessage("UIManager","change",-1);
    
        for(let manager of GeZiManager.YuanGong){
    let a=new Message("",[65],-1)
            manager.ReceiveMessage(a) ;   
    }
    MessageCenter.MakeMessage("AM",turn.turn,"getZB")
    
    GeZiManager.GeZis =GeZiManager.getF(GeZiManager.PCP.ZB,3)
    
    let c=new Message("",GeZiManager.GeZis,1);
    for (let m of GeZiManager.YuanGong) {
    
    
     
       // manager.getFar(n+GeZiManager.JL);
            
                m.red();
            
               m.ReceiveMessage(c);
          
    if(GeZiManager.BanMove.includes(m.ZB)){
    m.out();}
    console.log(GeZiManager.Tcharacter)
    }
    
      
    
    
    
    }
}



